'use strict';
import React from 'react'
import { render } from 'react-dom'
import { Provider} from 'react-redux'
import Routes from  '../app/routes/routes'
//import DevTools from './containers/DevTools'
import { createStore,compose ,applyMiddleware} from 'redux'
import thunk from 'redux-thunk';
import devTools from 'remote-redux-devtools';
import {browserHistory} from 'react-router';//browserHistory
import { syncHistoryWithStore} from 'react-router-redux'
import todoApp from './reducers'
import './css/index.less'
//import createLogger from 'redux-logger'
import injectTapEventPlugin from 'react-tap-event-plugin';
import FastClick from 'fastclick';
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
    //alert(navigator.userAgent);
    FastClick.attach(document.body);
} else if (/(Android)/i.test(navigator.userAgent)) {

} else {

};
FastClick.attach(document.body);
injectTapEventPlugin();
//const loggerMiddleware = createLogger()//如果没有客户端请自行引用
const enhancer = compose(
    applyMiddleware(thunk/*,loggerMiddleware*/ ),

    devTools({realtime:true})
);
let store = createStore(todoApp,enhancer);
devTools.updateStore(store);
const history = syncHistoryWithStore(browserHistory, store);
/*let xmlhttp;
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
        console.log(xmlhttp.responseText)
    }
};
xmlhttp.open("GET","/api",true);
xmlhttp.send();*/
let rootElement = document.getElementById('root');
render(
    <Provider store={store}>
        {Routes(history)}
        
    </Provider>,
    rootElement
);
//connect()(Router);